#include <stdio.h>

#include "cJSON.h"

int main()
{
    cJSON *cjson_test = NULL;
    cJSON *cjson_address = NULL;
    cJSON *cjson_skill = NULL;

     /* 创建一个JSON数据对象(链表头结点) */
    cjson_test = cJSON_CreateObject();
    cJSON_AddStringToObject(cjson_test,"name","mcnlover666"); //实际上就是创建数据结点，插到链表中
    cJSON_AddNumberToObject(cjson_test,"age",22);
    cJSON_AddNumberToObject(cjson_test,"weiWght",55.5);

     /* 添加一条字符串类型的JSON数据(添加一个链表节点) */
    cjson_address = cJSON_CreateObject();
    cJSON_AddStringToObject(cjson_address,"country","China");
    cJSON_AddNumberToObject(cjson_address,"zip-code",11111);

    cJSON_AddItemToObject(cjson_test,"address",cjson_address);

    cjson_skill = cJSON_CreateArray();
    cJSON_AddItemToArray(cjson_skill,cJSON_CreateString("C"));
    cJSON_AddItemToArray(cjson_skill,cJSON_CreateString("JAVA"));
    cJSON_AddItemToArray(cjson_skill,cJSON_CreateString("Python"));
    cJSON_AddItemToObject(cjson_test,"skill",cjson_skill);

    cJSON_AddFalseToObject(cjson_test,"student");

    char *str = cJSON_Print(cjson_test);

    printf("%s\n",str);


    return 0;
}
